package name.huzhenbo.java.patterns.decorator;

import java.util.*;

/**
 * Though it's not a good idea to implement SortedArrayList like this, but it's a good example for decorator.
 */
class SortedArrayList implements List {
    private ArrayList list;

    public SortedArrayList(ArrayList list) {
        ArrayList cloned = (ArrayList) list.clone();
        Collections.sort(cloned);
        this.list = cloned;
    }

    public int size() {
        return list.size();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean isEmpty() {
        return list.isEmpty();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean contains(Object o) {
        return list.contains(o);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public Iterator iterator() {
        return list.iterator();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public Object[] toArray() {
        return list.toArray();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean add(Object o) {
        return list.add(0);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean remove(Object o) {
        return list.remove(o);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean addAll(Collection c) {
        return list.addAll(c);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean addAll(int index, Collection c) {
        return list.addAll(index, c);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public void clear() {
        list.clear();
    }

    public Object get(int index) {
        return list.get(index);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public Object set(int index, Object element) {
        return list.set(index, element);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public void add(int index, Object element) {
        list.add(index, element);
    }

    public Object remove(int index) {
        return list.remove(index);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public int indexOf(Object o) {
        return list.indexOf(o);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public int lastIndexOf(Object o) {
        return list.lastIndexOf(o);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public ListIterator listIterator() {
        return list.listIterator();  //To change body of implemented methods use File | Settings | File Templates.
    }

    public ListIterator listIterator(int index) {
        return list.listIterator(index);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public List subList(int fromIndex, int toIndex) {
        return list.subList(fromIndex, toIndex);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean retainAll(Collection c) {
        return list.retainAll(c);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean removeAll(Collection c) {
        return list.removeAll(c);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean containsAll(Collection c) {
        return list.containsAll(c);  //To change body of implemented methods use File | Settings | File Templates.
    }

    public Object[] toArray(Object[] a) {
        return list.toArray(a);  //To change body of implemented methods use File | Settings | File Templates.
    }
}
